package com.example.minefieldkeepercloud.view.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.example.minefieldkeepercloud.R;
import com.example.minefieldkeepercloud.util.DisplayUtil;
import com.example.minefieldkeepercloud.util.TimeCountUtil;
import com.example.minefieldkeepercloud.util.ToastUtil;


public class DelayeDialog  extends Dialog {
//    private Button btn_cancel, btn_update;
    private Activity context;
    private TextView tv1,tv2;
   // private EditText edit_pool,edit_person;
    private AddDialog.OnAddClickListener onAddClickListener;
    private String title;
    private TimeCountUtil.FonfinishListener fonfinishListener;
    public DelayeDialog(Activity context,String title,TimeCountUtil.FonfinishListener fonfinishListener) {
        super(context, R.style.dialog);
        this.context = context;
        this.fonfinishListener = fonfinishListener;
        this.title=title;
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        LayoutInflater inflater = LayoutInflater.from(getContext());
        View view = inflater.inflate(R.layout.dialog_delaye, null);
        setContentView(view, new ViewGroup.LayoutParams(DisplayUtil.getWidthPixels(context)/2,
                DisplayUtil.getHeightPixels(context)/4));

         tv1 =  view.findViewById(R.id.tv_1);
         tv2=  view.findViewById(R.id.tv_2);
         tv2.setText(title);
        TimeCountUtil timeCountUtil = new TimeCountUtil(context, 30000, 1000, tv1, context.getResources().getColor(R.color.white), new TimeCountUtil.FonfinishListener() {
             @Override
             public void onfinish() {
                 dismiss();
                 fonfinishListener.onfinish();
                 ToastUtil.showToast(context,"请求操作失败");
             }
         });
         timeCountUtil.start();
         this.setCanceledOnTouchOutside(false);
         this.setCancelable(false);

//        btn_update =  view.findViewById(R.id.btn_update);
//        edit_pool =  view.findViewById(R.id.edit_pool);
//        edit_person =  view.findViewById(R.id.edit_person);




    }

    @Override
    public void setOnDismissListener( DialogInterface.OnDismissListener listener) {
        super.setOnDismissListener(listener);
    }
}
